package xyz.aikids.spring.modulith.notification;

import lombok.extern.slf4j.Slf4j;
import org.springframework.modulith.ApplicationModuleListener;
import org.springframework.stereotype.Service;
import xyz.aikids.spring.modulith.notification.internal.Notification;

/**
 * @author liushouqian
 * @date 2023/7/19 09:32
 * @description
 */
@Slf4j
@Service
public class NotificationService {
    public void createNotification(NotificationDTO notification) {
        log.info("Received notification by module dependency for product {} in date {} by {}.",
                notification.getProductName(),
                notification.getDate(),
                notification.getFormat());
    }

//    @ApplicationModuleListener
//    public void notificationEvent(NotificationDTO event) {
//        Notification notification = toEntity(event);
//        log.info("***** Received notification by event for product {} in date {} by {}.",
//                notification.getProductName(),
//                notification.getDate(),
//                notification.getFormat());
//    }
//
//    private Notification toEntity(NotificationDTO dto) {
//        return new Notification(dto.getDate(), dto.getFormat(), dto.getProductName());
//    }
}
